<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%
Integer flight_id = (Integer)request.getAttribute("flightid");
Integer customer_id = (Integer)request.getAttribute("customerid");
String name = (String)request.getAttribute("name");
String date = (String)request.getAttribute("date");
// List datelist = (List)request.getAttribute("datelist");
List<Integer> seatlist = (List<Integer>)request.getAttribute("seatlist");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FlyGreenwich's Aircraft</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

function getSeat(seat){
	
	<% for(int i=0; i<seatlist.size(); i++){%>
	if (seat == <%=seatlist.get(i)%>){
		alert("This seat is not available");
		return false;
	}
	<%}%>
	document.getElementById("decide").value= seat;
	return false;
}

</script>

</head>
<body>

<a name="top" id="top"></a>
<center>
	<jsp:include page="/WEB-INF/pages/menu_bar.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/header.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/content.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/sidebar.jsp"></jsp:include>
	<div id="mainbar">
      <h1><a name="css" id="css"></a>Flight Chosen</h1>
      <form name="flight_chosen" action="chooseFlightServlet" method="post">
      <table>
      	<tr>
	  		<td>Hello, <%=name %></td>
	  	</tr>
      	<%if (seatlist.size() != 0){ %>
	  	<tr>
	  		<td><b>Take note that the below seat no is not available. </b></td>
	  	</tr>
	  	<tr>
	  		<td>
	  		<table>
	  		<%for(int i=0;i<seatlist.size();i++){%>
	  			<tr>
	  				<td>
	  					<%= seatlist.get(i) %>
	  				</td>
	  			</tr>
	  		<% }%>
	  		</table>
	  		</td>
	  	</tr>
	  	<%} %>
      </table>
	  <table>
	  	<tr>
	  		<td><b>Your chosen date and time: </b></td>
	  	</tr>

	  	<tr>
	  		<td><%= date %> Time: 09:00 AM</td>
	  	</tr>
	  	
	  	<tr>
	  		<td><b>Please choose your seat </b></td>
	  	</tr>
	  	<tr>
	  		<td>
	  			<table>
	  				<tr>
	  				<%for (int i=1; i<41; i++){ %>
	  					<td><button id="seatclick" onClick="return getSeat('<%=i %>');"><%=i %></button></td>
	  					<%if(i % 4 == 0){ %>
	  					</tr>
	  					<tr>
	  					<%} } %>
	  				</tr>
	  			</table>
	  		</td>
	  	</tr>
	  	
	  	<tr>
	  		<td><b>Your chosen seat:</b></td>
	  		<td>
	  			<input type = "text" id="decide" value="" name="decide"></input>
	  		</td>
	  	</tr>
	  </table>
	  <input type="hidden" name="name" value="<%=name%>">
	  <input type="hidden" name="customer_id" value="<%=customer_id%>">
	  <input type="hidden" name="flight_id" value="<%=flight_id%>">
	  <input type="hidden" name="date" value="<%=date%>">
	  <input type="submit" name="submitbtn" value="Book flight"/>
	  </form>
    </div>
    <br><br><br>
	<jsp:include page="/WEB-INF/pages/footer.jsp"></jsp:include>
</center>
</body>
</html>


